package com.example.springboot.util;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public  class ResponseUtil {
	private final static Integer SUCCESS_CODE=0;
	private final static Integer FAIL_CODE=1;
	public static String getSuccess(Object data,Long count){
		JSONObject jsonObject=new JSONObject();
		jsonObject.put("code", SUCCESS_CODE);
		jsonObject.put("data", data);
		jsonObject.put("count", count);
		return JSON.toJSONString(jsonObject);
	}
	public static String getFail(Object msg){
		JSONObject jsonObject=new JSONObject();
		jsonObject.put("code",FAIL_CODE );
		jsonObject.put("msg", msg);
		return JSON.toJSONString(jsonObject);
	}
	public static String getSuccess(){
		JSONObject jsonObject=new JSONObject();
		jsonObject.put("code",SUCCESS_CODE );
		return JSON.toJSONString(jsonObject);
	}
	public static String getSuccess(String msg){
		JSONObject jsonObject=new JSONObject();
		jsonObject.put("code",SUCCESS_CODE );
		jsonObject.put("msg",msg );
		return JSON.toJSONString(jsonObject);
	}
	public static String getSuccess(String msg,Object data){
		JSONObject jsonObject=new JSONObject();
		jsonObject.put("code",SUCCESS_CODE );
		jsonObject.put("msg",msg );
		jsonObject.put("data",data);
		return JSON.toJSONString(jsonObject);
	}
}
